package org.spindle.dungeon.entities;

import org.newdawn.slick.GameContainer;
import org.spindle.dungeon.Constants;
import org.spindle.dungeon.EntityManager;
import org.spindle.dungeon.LevelProperties;

public class Spawner extends GeneralEntity {


    @Override
    protected void initialize() {
        collidable = false;
        triggerable = true;
        staticImage = true;
        spritesList.add(Constants.SPRITE_SHEET.getSprite(4, 7));

        layer = 11;
    }

    @Override
    public void update(GameContainer gc, LevelProperties props) {

    }

    @Override
    public void trigger(GeneralEntity by) {

        if (by.type == EntitiesConstants.LEVER) {
            GeneralEntity worm = new Worm();
            worm.x = (int) Math.round(this.x - 32 + 64 * Math.random());
            worm.y = (int) Math.round(this.y - 32 + 64 * Math.random());
            EntityManager.getInstance().registerEntity(worm);
        }
    }
}
